Skip to content

fix(rules): report proposal resolution failures instead of pretending success - #87

Open
Lafnaps wants to merge 1 commit into
bcurts:mainfrom
Lafnaps:fix/rules-proposal-resolution-errors
Open

fix(rules): report proposal resolution failures instead of pretending success#87
Lafnaps wants to merge 1 commit into
bcurts:mainfrom
Lafnaps:fix/rules-proposal-resolution-errors

Conversation

@Lafnaps

@Lafnaps Lafnaps commented Aug 1, 2026

Copy link
Copy Markdown

Approve a rule proposal while 10 rules are already active (MAX_ACTIVE_RULES) and watch it "activate": resolve_rule_proposal calls rules.activate(rule_id), ignores that it returned None, stamps the message metadata activated, and returns 200. The proposal card renders "Activated" forever while the rule is still pending in the Rules panel — the two permanently disagree, and nothing in the UI hints that the click did nothing. The same pattern sits on every branch of the endpoint (activate, draft, dismiss — the store also returns None for an unknown or deleted rule id) and on demote_rule_proposal.

The frontend has the matching half of the problem: resolveRuleProposal/dismissRuleProposal never check response.ok, so even an honest 4xx dies as a console.error with no user feedback.

The backend now checks each store call's return value; on failure it answers 409 with an error body and leaves the message metadata alone. The frontend checks response.ok and surfaces the error through the existing showToast, so the card keeps its real pending state. Happy path unchanged; ?v= bumped for rules-panel.js.

Tests: new tests/test_rule_proposals.py — activate at the active-rule limit → 409 and metadata stays pending; activate a deleted rule id → 409, metadata unchanged; happy-path activate → 200, metadata activated, rule active; demote of a deleted rule → 409. 4 passed. Full suite: 85 passed (81 on current main).

Also verified against a live server with a scripted browser, seeding rules through the store and running the same scenario on this branch and on main. With 10 active rules, clicking Activate on a pending proposal now shows the error toast and the card keeps its buttons, and the server keeps the rule pending. On main the card flips to "Activated" and the message metadata records activated while the rule's real status stays pending — the permanent disagreement described above. With 9 active rules the card resolves and the rule activates exactly as before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant